//
//  AZSendDataController.m
//  AZBLE
//
//  Created by AZ-Mac on 2017/5/4.
//  Copyright © 2017年 AZ-Mac. All rights reserved.
//

#import "AZSendDataController.h"
#import <SWHex.h>
@interface AZSendDataController ()
@property (weak, nonatomic) IBOutlet UITextField *inputTF;

@end

@implementation AZSendDataController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrameNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self.inputTF becomeFirstResponder];
}
- (void)keyboardWillChangeFrameNotification:(NSNotification *)note
{
    CGRect keyEndRect =[note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    double duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    
    [UIView animateWithDuration:duration animations:^{
        CGFloat changY = AZScreenH - keyEndRect.origin.y;
        self.view.transform = CGAffineTransformMakeTranslation(0, -changY);
    }];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}
- (IBAction)sendClick:(id)sender {
    
    [self.view endEditing:YES];
    
//    NSData *data = [self.inputTF.text dataFromBytesString];
    
    if (_sendValue) {
        _sendValue(self.inputTF.text);
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

@end
